﻿using System;
using System.Data;
namespace E2_WEBSITE.Code.Admin
{
    public class AdsInfo
    {
        public int ID { get; set; }
        public DateTime StartTime { get; set; }
        public DateTime EndTime { get; set; }
        public int Position { get; set; }
        public int Price { get; set; }
        public int User { get; set; }
        public string Image { get; set; }
        public string Navigate { get; set; }

        public AdsInfo(DateTime start, DateTime end, int position, int price, string image, string nav)
        {
            this.StartTime = start;
            this.EndTime = end;
            this.Position = position;
            this.Price = price;
            this.Image = image;
            this.Navigate = nav;
        }

        static public AdsInfo Load(DataTable data)
        {
            AdsInfo ads = null;

            ads = new AdsInfo(
                DateTime.ParseExact(data.Rows[0]["NgayBatDau"].ToString(), Utilities.DateTimeFormatString, null),
                DateTime.ParseExact(data.Rows[0]["NgayKetThuc"].ToString(), Utilities.DateTimeFormatString, null),
                int.Parse(data.Rows[0]["ViTri"].ToString()),
                int.Parse(data.Rows[0]["Gia"].ToString()),
                data.Rows[0]["HinhAnh"].ToString(),
                data.Rows[0]["DuongDan"].ToString());
            ads.ID = int.Parse(data.Rows[0]["ID"].ToString());
            ads.User = int.Parse(data.Rows[0]["idKhachHang"].ToString());

            return ads;
        }
    }
}